package com.neudeu.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.neudeu.dao.IUserDAO;
import com.neudeu.dto.UserLogin;
import com.neudeu.entity.UserEntity;
import com.neudeu.page.Page;
import com.neudeu.service.UserService;

@Service
public class UserServiceImpl implements UserService {
     
	@Autowired
	private IUserDAO userdao;
	
	public List<UserEntity> all() {
		
		return userdao.getAll();
	}

	public Page<UserEntity> allpage(int n) {
		
		Page<UserEntity> page=new Page<UserEntity>();
		page.setDataCount(userdao.userCount(0));
		page.setPageNum(n);
		page.setData(userdao.getByLevelLimit(0, (page.getPageNum()-1)*page.getPageNumber(), page.getPageNumber()));
		return page;
	}

	public UserEntity getOne(UserLogin user) {
		return userdao.getByNamePassword(0, user.getUsername(), user.getPassword());
	}

}
